#include <graphics.h>
#include <conio.h>
#include <string.h>
#include<stdio.h>
#include<windows.h>
#include<stdlib.h>
#include<time.h>
#pragma comment(lib,"Winmm.lib")

#define x1 60//两个直方块间距离
#define x2 70//直方块和三角块间横距离
#define x3 50//两个三角块间距离
#define y2 20//直方块和三角块间纵距离
#define width 1065
#define high 1057
int feiji1_x[5], feiji1_y[5], feiji2_x[5], feiji2_y[5], feiji3_x[5], feiji3_y[5], feiji4_x[5], feiji4_y[5], feijix_x, feijix_y; //飞机位置
int a[width][high];
int step[5] = { -1 };
int step2[5] = { -1 };
int flag[5] = { 0 };
int flag1[5] = { 0 };
int original_x[9], original_y[9];
int Gamestart = 0;//1表示单人；2表示双人

IMAGE s1, s2, s3, s4, s5, s6, s7;//骰子的图像

IMAGE img_bk;	//定义IMAGE对象背景
IMAGE startbk, p1, p2;//开始界面图片
IMAGE img_feiji, img_feiji1, img_feiji2, img_feiji3, img_feiji4, img_feiji5, img_feiji6, img_feiji7, img_feiji8, img_feiji9, img_feiji10, img_feiji11, img_feiji12, img_feiji13, img_feiji14, img_feiji15, img_feiji16, img_feijix, img_win;
void touzi(int n);
void gameover();

void startup()
{
	int start1_x = 110, start1_y = 190, start2_x = 510, start2_y = 190;//开始界面的选择
	initgraph(801, 371);
	loadimage(&startbk, "E:\\startbk.png");
	loadimage(&p1, "E:\\1p.png");
	loadimage(&p2, "E:\\2p.png");
	BeginBatchDraw;
	while (Gamestart == 0)
	{
		MOUSEMSG m;//鼠标控制
		m = GetMouseMsg();
		putimage(0, 0, &startbk);
		putimage(100, 180, &p1);
		putimage(500, 180, &p2);

		if (m.uMsg == WM_LBUTTONDOWN && Gamestart == 0 && ((abs(m.x - start1_x) + abs(m.y - start1_y)) < 180))//单人游戏
		{
			Gamestart = 1;
		}
		if (m.uMsg == WM_LBUTTONDOWN && Gamestart == 0 && ((abs(m.x - start2_x) + abs(m.y - start2_y)) < 180))//双人人游戏
		{
			Gamestart = 2;
		}
	}
	closegraph();
}
void start()
{
	//飞机初始位置定义
	feiji1_x[1] = 50;
	feiji1_y[1] = 50;
	feiji1_x[2] = 160;
	feiji1_y[2] = 50;
	feiji1_x[3] = 50;
	feiji1_y[3] = 150;
	feiji1_x[4] = 160;
	feiji1_y[4] = 150;
	feiji2_x[1] = 840;
	feiji2_y[1] = 840;
	feiji2_x[2] = 950;
	feiji2_y[2] = 840;
	feiji2_x[3] = 840;
	feiji2_y[3] = 940;
	feiji2_x[4] = 950;
	feiji2_y[4] = 940;
	feiji3_x[1] = 60;
	feiji3_y[1] = 830;
	feiji3_x[2] = 160;
	feiji3_y[2] = 830;
	feiji3_x[3] = 60;
	feiji3_y[3] = 940;
	feiji3_x[4] = 160;
	feiji3_y[4] = 940;
	feiji4_x[1] = 840;
	feiji4_y[1] = 50;
	feiji4_x[2] = 950;
	feiji4_y[2] = 50;
	feiji4_x[3] = 840;
	feiji4_y[3] = 160;
	feiji4_x[4] = 950;
	feiji4_y[4] = 160;
	original_x[1] = 50;
	original_x[2] = 160;
	original_x[3] = 50;
	original_x[4] = 160;
	original_x[5] = 840;
	original_x[6] = 950;
	original_x[7] = 840;
	original_x[8] = 950;
	original_y[1] = 50;
	original_y[2] = 50;
	original_y[3] = 150;
	original_y[4] = 150;
	original_y[5] = 840;
	original_y[6] = 840;
	original_y[7] = 940;
	original_y[8] = 940;



	loadimage(&startbk, "E:\\startbk.png");
	loadimage(&p1, "E:\\1p.png");
	loadimage(&p2, "E:\\2p.png");


	loadimage(&img_bk, "E:\\background.jpg");	//读取图片到img对象中
	loadimage(&img_feiji, "E:\\feiji.jpg");   //读取图片到img对象中
	loadimage(&img_feiji1, "E:\\feiji1.jpg");   //读取图片到img对象中
	loadimage(&img_feiji2, "E:\\feiji1.jpg");   //读取图片到img对象中
	loadimage(&img_feiji3, "E:\\feiji1.jpg");   //读取图片到img对象中
	loadimage(&img_feiji4, "E:\\feiji1.jpg");   //读取图片到img对象中
	loadimage(&img_feiji5, "E:\\feiji4.jpg");   //读取图片到img对象中
	loadimage(&img_feiji6, "E:\\feiji4.jpg");   //读取图片到img对象中
	loadimage(&img_feiji7, "E:\\feiji4.jpg");   //读取图片到img对象中
	loadimage(&img_feiji8, "E:\\feiji4.jpg");   //读取图片到img对象中
	loadimage(&img_feiji9, "E:\\feiji3.jpg");   //读取图片到img对象中
	loadimage(&img_feiji10, "E:\\feiji3.jpg");   //读取图片到img对象中
	loadimage(&img_feiji11, "E:\\feiji3.jpg");   //读取图片到img对象中
	loadimage(&img_feiji12, "E:\\feiji3.jpg");   //读取图片到img对象中
	loadimage(&img_feiji13, "E:\\feiji2.jpg");   //读取图片到img对象中
	loadimage(&img_feiji14, "E:\\feiji2.jpg");   //读取图片到img对象中
	loadimage(&img_feiji15, "E:\\feiji2.jpg");   //读取图片到img对象中
	loadimage(&img_feiji16, "E:\\feiji2.jpg");   //读取图片到img对象中
	loadimage(&img_feijix, "E:\\feiji5.jpg");   //读取图片到img对象中
	loadimage(&s1, "E:\\1a.gif");//骰子
	loadimage(&s2, "E:\\2a.gif");
	loadimage(&s3, "E:\\3a.gif");
	loadimage(&s4, "E:\\4a.gif");
	loadimage(&s5, "E:\\5a.gif");
	loadimage(&s6, "E:\\6a.gif");
	loadimage(&s7, "E:\\0.gif");//去白边
	loadimage(&img_win, "E:\\win.png"); //胜利

	Sleep(50);



}
void show()
{
	putimage(0, 0, &img_bk);
	putimage(feiji1_x[1], feiji1_y[1], &img_feiji, NOTSRCERASE);
	putimage(feiji1_x[1], feiji1_y[1], &img_feiji1, SRCINVERT);
	putimage(feiji1_x[2], feiji1_y[2], &img_feiji, NOTSRCERASE);
	putimage(feiji1_x[2], feiji1_y[2], &img_feiji2, SRCINVERT);
	putimage(feiji1_x[3], feiji1_y[3], &img_feiji, NOTSRCERASE);
	putimage(feiji1_x[3], feiji1_y[3], &img_feiji3, SRCINVERT);
	putimage(feiji1_x[4], feiji1_y[4], &img_feiji, NOTSRCERASE);
	putimage(feiji1_x[4], feiji1_y[4], &img_feiji4, SRCINVERT);
	putimage(feiji2_x[1], feiji2_y[1], &img_feiji, NOTSRCERASE);
	putimage(feiji2_x[1], feiji2_y[1], &img_feiji5, SRCINVERT);
	putimage(feiji2_x[2], feiji2_y[2], &img_feiji, NOTSRCERASE);
	putimage(feiji2_x[2], feiji2_y[2], &img_feiji6, SRCINVERT);
	putimage(feiji2_x[3], feiji2_y[3], &img_feiji, NOTSRCERASE);
	putimage(feiji2_x[3], feiji2_y[3], &img_feiji7, SRCINVERT);
	putimage(feiji2_x[4], feiji2_y[4], &img_feiji, NOTSRCERASE);
	putimage(feiji2_x[4], feiji2_y[4], &img_feiji8, SRCINVERT);
	putimage(feiji3_x[1], feiji3_y[1], &img_feiji, NOTSRCERASE);
	putimage(feiji3_x[1], feiji3_y[1], &img_feiji9, SRCINVERT);
	putimage(feiji3_x[2], feiji3_y[2], &img_feiji, NOTSRCERASE);
	putimage(feiji3_x[2], feiji3_y[2], &img_feiji10, SRCINVERT);
	putimage(feiji3_x[3], feiji3_y[3], &img_feiji, NOTSRCERASE);
	putimage(feiji3_x[3], feiji3_y[3], &img_feiji11, SRCINVERT);
	putimage(feiji3_x[4], feiji3_y[4], &img_feiji, NOTSRCERASE);
	putimage(feiji3_x[4], feiji3_y[4], &img_feiji12, SRCINVERT);
	putimage(feiji4_x[1], feiji4_y[1], &img_feiji, NOTSRCERASE);
	putimage(feiji4_x[1], feiji4_y[1], &img_feiji13, SRCINVERT);
	putimage(feiji4_x[2], feiji4_y[2], &img_feiji, NOTSRCERASE);
	putimage(feiji4_x[2], feiji4_y[2], &img_feiji14, SRCINVERT);
	putimage(feiji4_x[3], feiji4_y[3], &img_feiji, NOTSRCERASE);
	putimage(feiji4_x[3], feiji4_y[3], &img_feiji15, SRCINVERT);
	putimage(feiji4_x[4], feiji4_y[4], &img_feiji, NOTSRCERASE);
	putimage(feiji4_x[4], feiji4_y[4], &img_feiji16, SRCINVERT);

	FlushBatchDraw();
	Sleep(100);
}
void updatewithoutInput()
{



}
void updatewithInput()
{
	int fly1[5] = { 0 };//是否飞行
	int fly[5] = { 0 };//是否飞行
	char input;
	int n;
	int i;
	int k, l = 0;
	input = _getch();
	if (Gamestart == 2)
	{
		if (input == 's')
		{
			if (flag1[0] == 0)
			{
				srand(time(NULL));
				n = rand() % 6 + 1;
				touzi(n);
				Sleep(1000);
				if (n == 6)
				{
					feiji1_x[1] = 30;
					feiji1_y[1] = 250;
					step[1] = 0;
					putimage(feiji1_x[1], feiji1_y[1], &img_feiji, NOTSRCERASE);
					putimage(feiji1_x[1], feiji1_y[1], &img_feiji1, SRCINVERT);
					flag1[1] = 1;
					flag1[0] = 1;
				}
			}
			if (flag1[0] == 1)
			{
				srand(time(NULL));
				n = rand() % 6 + 1;
				touzi(n);
				Sleep(1000);
				scanf_s("%d", &i);
				if (flag1[i] == 0 && n == 6)//飞机出发
				{
					feiji1_x[i] = 30;
					feiji1_y[i] = 250;
					step[i] = 0;
					putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
					putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
					flag1[i] = 1;
				}
				else if (flag1[i] == 1)
				{
					fly1[i] = 1;
				}
				for (i = 1; i < 5; i++)
				{
					if (fly1[i] == 1)
					{
						step[i] += n;
						if (step[i] % 4 == 2 && step[i] != 18 && step[i] < 50)
						{
							step[i] += 4;
						}
						if (step[i] == 18)
						{
							step[i] = 30;
						}
						if (step[i] == 1)
						{
							feiji1_x[i] = 70;
							feiji1_y[i] = 300;
						}
						else if (step[i] > 1 && step[i] < 5)
						{
							feiji1_x[i] = 140 + 60 * (step[i] - 2);
							feiji1_y[i] = 280;
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
						}
						else if (step[i] > 4 && step[i] < 9)
						{
							feiji1_x[i] = 290;
							feiji1_y[i] = 270;
							feiji1_y[i] -= 60 * (step[i] - 5);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
						}
						else if (step[i] > 8 && step[i] < 14)
						{
							feiji1_x[i] = 380;
							feiji1_x[i] += 60 * (step[i] - 9);
							feiji1_y[i] = 40;
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
						}
						else if (step[i] > 13 && step[i] < 18)
						{
							feiji1_x[i] = 710;
							feiji1_y[i] = 70;
							feiji1_y[i] += 60 * (step[i] - 14);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
						}
						else if (step[i] > 18 && step[i] < 22)
						{
							feiji1_x[i] = 750;
							feiji1_x[i] += 60 * (step[i] - 18);
							feiji1_y[i] = 280;
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
						}
						else if (step[i] == 18)
						{
							step[i] = 30;
						}
						else if (step[i] > 21 && step[i] < 27)
						{
							feiji1_x[i] = 950;
							feiji1_y[i] = 370;
							feiji1_y[i] += 60 * (step[i] - 22);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
						}
						else if (step[i] > 26 && step[i] < 31)
						{
							feiji1_x[i] = 920;
							feiji1_x[i] -= 60 * (step[i] - 27);
							feiji1_y[i] = 700;
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
						}
						else if (step[i] > 30 && step[i] < 35)
						{
							feiji1_x[i] = 710;
							feiji1_y[i] = 740;
							feiji1_y[i] += 60 * (step[i] - 31);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
						}
						else if (step[i] > 34 && step[i] < 40)
						{
							feiji1_x[i] = 620;
							feiji1_x[i] -= 60 * (step[i] - 35);
							feiji1_y[i] = 940;
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
						}
						else if (step[i] > 39 && step[i] < 44)
						{
							feiji1_x[i] = 290;
							feiji1_y[i] = 910;
							feiji1_y[i] -= 60 * (step[i] - 40);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
						}
						else if (step[i] > 43 && step[i] < 48)
						{
							feiji1_x[i] = 250;
							feiji1_x[i] -= 60 * (step[i] - 44);
							feiji1_y[i] = 710;
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
						}
						else if (step[i] > 47 && step[i] < 51)
						{
							feiji1_x[i] = 50;
							feiji1_y[i] = 620;
							feiji1_y[i] -= 60 * (step[i] - 48);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
						}
						else if (step[i] > 50 && step[i] < 56)
						{
							feiji1_x[i] = 140;
							feiji1_x[i] += 60 * (step[i] - 51);
							feiji1_y[i] = 500;
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
						}
						else if (step[i] > 56)
						{
							step[i] = 112 - step[i];
							feiji1_x[i] = 140;
							feiji1_x[i] += 60 * (step[i] - 51);
							feiji1_y[i] = 500;
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
						}
						else if (step[i] == 56)
						{
							feiji1_x[i] = -100;
							feiji1_y[i] = -100;
							feijix_x = 50;
							feijix_y = 50;
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji1_x[i], feiji1_y[i], &img_feiji1, SRCINVERT);
							putimage(feijix_x, feijix_y, &img_feiji, NOTSRCERASE);
							putimage(feijix_x, feijix_y, &img_feijix, SRCINVERT);
							flag1[i] = 2;
						}

						l = 0;
						for (k = 1; k < 5; k++)
						{
							if (step[i] == step2[k] - 26)
							{
								step2[k] = -1;
								flag[k] = 0;
								feiji2_x[k] = original_x[k + 4];
								feiji2_y[k] = original_y[k + 4];
								putimage(feiji2_x[k], feiji2_y[k], &img_feiji, NOTSRCERASE);
								putimage(feiji2_x[k], feiji2_y[k], &img_feiji5, SRCINVERT);
							}
							if (flag[k] !=0)
								l = 1;
							if (l == 0)
							{
								flag[0] = 0;//全员回家
							}

						}
						if (flag1[1] == 2 && flag1[2] == 2 && flag1[3] == 2 && flag1[4] == 2)
						{
							putimage(25, 30, &img_win);
							gameover();
						}

					}
					fly1[i] = 0;
				}
			}
		}
		if (input == 'd')
		{
			if (flag[0] == 0)
			{
				srand(time(NULL));
				n = rand() % 6 + 1;
				touzi(n);
				Sleep(1000);
				if (n == 6)
				{
					feiji2_x[1] = 970;
					feiji2_y[1] = 740;
					step2[1] = 0;
					putimage(feiji2_x[1], feiji2_y[1], &img_feiji, NOTSRCERASE);
					putimage(feiji2_x[1], feiji2_y[1], &img_feiji5, SRCINVERT);
					flag[1] = 1;
					flag[0] = 1;
				}
			}
			if (flag[0] == 1)
			{
				srand(time(NULL));
				n = rand() % 6 + 1;
				touzi(n);
				Sleep(1000);
				scanf_s("%d", &i);
				if (flag[i] == 0 && n == 6)//飞机出发
				{
					feiji2_x[i] = 970;
					feiji2_y[i] = 740;
					step2[i] = 0;
					putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
					putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
					flag[i] = 1;
				}
				else if (flag[i] == 1)
				{
					fly[i] = 1;
				}
				for (i = 1; i < 5; i++)
				{
					if (fly[i] == 1)
					{
						step2[i] += n;
						if (step2[i] % 4 == 2 && step2[i] != 18 && step2[i] < 50)
						{
							step2[i] += 4;
						}
						if (step2[i] == 18)
						{
							step2[i] = 30;
						}
						if (step2[i] == 1)
						{
							feiji2_x[i] = 920;
							feiji2_y[i] = 690;
						}
						else if (step2[i] > 1 && step2[i] < 5)
						{
							feiji2_x[i] = 850;
							feiji2_x[i] -= 60 * (step2[i] - 2);
							feiji2_y[i] = 700;
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] > 4 && step2[i] < 9)
						{
							feiji2_x[i] = 710;
							feiji2_y[i] = 740;
							feiji2_y[i] += 60 * (step2[i] - 5);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] > 8 && step2[i] < 14)
						{
							feiji2_x[i] = 620;
							feiji2_x[i] -= 60 * (step2[i] - 9);
							feiji2_y[i] = 940;
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] > 13 && step2[i] < 18)
						{
							feiji2_x[i] = 290;
							feiji2_y[i] = 910;
							feiji2_y[i] -= 60 * (step2[i] - 14);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] > 18 && step2[i] < 22)
						{
							feiji2_x[i] = 250;
							feiji2_x[i] -= 60 * (step2[i] - 19);
							feiji2_y[i] = 710;
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] > 21 && step2[i] < 27)
						{
							feiji2_x[i] = 50;
							feiji2_y[i] = 620;
							feiji2_y[i] -= 60 * (step2[i] - 22);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] == 27)
						{
							feiji2_x[i] = 70;
							feiji2_y[i] = 300;
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] > 27 && step2[i] < 31)
						{
							feiji2_x[i] = 140 + 60 * (step2[i] - 28);
							feiji2_y[i] = 280;
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] > 30 && step2[i] < 35)
						{
							feiji2_x[i] = 290;
							feiji2_y[i] = 270;
							feiji2_y[i] -= 60 * (step2[i] - 31);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] > 34 && step2[i] < 40)
						{
							feiji2_x[i] = 380;
							feiji2_x[i] += 60 * (step2[i] - 35);
							feiji2_y[i] = 40;
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] > 39 && step2[i] < 44)
						{
							feiji2_x[i] = 710;
							feiji2_y[i] = 70;
							feiji2_y[i] += 60 * (step2[i] - 40);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] > 43 && step2[i] < 48)
						{
							feiji2_x[i] = 750;
							feiji2_x[i] += 60 * (step2[i] - 44);
							feiji2_y[i] = 280;
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] > 47 && step2[i] < 51)
						{
							feiji2_x[i] = 950;
							feiji2_y[i] = 370;
							feiji2_y[i] += 60 * (step2[i] - 48);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] > 50 && step2[i] < 56)
						{
							feiji2_x[i] = 850;
							feiji2_x[i] -= 60 * (step2[i] - 51);
							feiji2_y[i] = 500;
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] > 56)
						{
							step2[i] = 112 - step2[i];
							feiji2_x[i] = 850;
							feiji2_x[i] -= 60 * (step2[i] - 51);
							feiji2_y[i] = 500;
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
						}
						else if (step2[i] == 56)
						{
							feiji2_x[i] = -100;
							feiji2_y[i] = -100;
							feijix_x = 840;
							feijix_y = 840;
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji, NOTSRCERASE);
							putimage(feiji2_x[i], feiji2_y[i], &img_feiji5, SRCINVERT);
							putimage(feijix_x, feijix_y, &img_feiji, NOTSRCERASE);
							putimage(feijix_x, feijix_y, &img_feijix, SRCINVERT);
							flag[i] = 2;
						}

						l = 0;
						for (k = 1; k < 5; k++)
						{
							if (step2[i] == step[k] - 26)
							{
								step[k] = -1;
								flag1[k] = 0;
								feiji1_x[k] = original_x[k];
								feiji1_y[k] = original_y[k];
								putimage(feiji1_x[k], feiji1_y[k], &img_feiji, NOTSRCERASE);
								putimage(feiji1_x[k], feiji1_y[k], &img_feiji1, SRCINVERT);
							}
							if (flag1[k] == 1)
								l = 1;
							if (l == 0)
							{
								flag[0] = 0;//全员回家
							}
						}
						if (flag[1] == 2 && flag[2] == 2 && flag[3] == 2 && flag[4] == 2)
						{
							putimage(808, 805, &img_win);
							Sleep(5000);
							gameover();
						}
					}
					fly[i] = 0;
				}

			}

		}
	}
}
void touzi(int n)
{

	int j = 0;
	BeginBatchDraw();
	mciSendString("close music ", NULL, 0, NULL);
	mciSendString("open E:\\touzi.mp3 alias music", NULL, 0, NULL);//摇骰子音效
	mciSendString("play music ", NULL, 0, NULL);//播放

	while (j < 17)
	{
		putimage(100, 120, &s7, NOTSRCERASE);
		putimage(100, 120, &s1, SRCINVERT);
		Sleep(25);
		putimage(100, 120, &s7, NOTSRCERASE);
		putimage(100, 120, &s2, SRCINVERT);
		Sleep(25);
		putimage(100, 120, &s7, NOTSRCERASE);
		putimage(100, 120, &s3, SRCINVERT);
		Sleep(25);
		putimage(100, 120, &s7, NOTSRCERASE);
		putimage(100, 120, &s4, SRCINVERT);
		Sleep(25);
		putimage(100, 120, &s7, NOTSRCERASE);
		putimage(100, 120, &s5, SRCINVERT);
		Sleep(25);
		putimage(100, 120, &s7, NOTSRCERASE);
		putimage(100, 120, &s6, SRCINVERT);
		Sleep(25);
		FlushBatchDraw();
		EndBatchDraw();
		j++;
	}
	BeginBatchDraw();
	if (n == 5)
	{
		putimage(100, 120, &s7, NOTSRCERASE);
		putimage(100, 120, &s5, SRCINVERT);
	}
	if (n == 1)
	{
		putimage(100, 120, &s7, NOTSRCERASE);
		putimage(100, 120, &s1, SRCINVERT);
	}
	if (n == 2)
	{
		putimage(100, 120, &s7, NOTSRCERASE);
		putimage(100, 120, &s2, SRCINVERT);
	}
	if (n == 3)
	{
		putimage(100, 120, &s7, NOTSRCERASE);
		putimage(100, 120, &s3, SRCINVERT);
	}
	if (n == 4)
	{
		putimage(100, 120, &s7, NOTSRCERASE);
		putimage(100, 120, &s4, SRCINVERT);
	}
	if (n == 6)
	{
		putimage(100, 120, &s7, NOTSRCERASE);
		putimage(100, 120, &s6, SRCINVERT);
	}

	FlushBatchDraw();
	EndBatchDraw();
}

void gameover()
{
	EndBatchDraw();
	_getch();
	closegraph();
}
int main()
{

	start();
	startup();
	initgraph(width, high);
	while (1)
	{


		if (Gamestart != 0)
		{
			show();

			updatewithoutInput();
			updatewithInput();
		}

	}
	gameover();
	return 0;
}
